package com.wanho.java158.impl;

import com.github.pagehelper.PageInfo;
import com.wanho.java157.*;
import com.wanho.java157.po.BaseEntity;
import com.wanho.java158.*;
import com.wanho.java157.vo.CustomerVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.Serializable;
import java.util.List;

@Service
public class CustomerServiceImpl implements CustomerService   {
    @Autowired
    private CustomerVoMapper customerVoMapper;
    @Autowired
    private CarMapper carMapper;
    @Autowired
    private CustomerLoginMapper customerLoginMapper;
    @Autowired
    private CustomerDetailMapper customerDetailMapper;
    @Autowired
    private OrdersMapper ordersMapper;
    @Autowired
    private ServesMapper servesMapper;




    @Override
    public List<CustomerVo> selectAll() {
        return customerVoMapper.selectAll();
    }

    @Override
    public boolean delete(Integer id) {
        System.out.println(id);
        Car car = carMapper.selectByCustomerId(id);
        System.out.println(car);
        if(car!=null){
            carMapper.deleteByCustomerId(id);
        }
        CustomerLogin customerLogin = customerLoginMapper.selectByCustomerId(id);
        System.out.println(customerLogin);
        if(customerLogin!=null){
            customerLoginMapper.deleteByCustomerId(id);
        }
        CustomerDetail customerDetail = customerDetailMapper.selectByCustomerId(id);
        System.out.println(customerDetail);
        if(customerDetail!=null){
            customerDetailMapper.deleteByCustomerId(id);
        }

        Serves serves = servesMapper.selectByCustomerId(id);
        System.out.println(serves);
        if(serves!=null){
            servesMapper.deleteByCustomerId(id);
        }
        Orders orders = ordersMapper.selectByCustomerId(id);
        System.out.println(orders);
        if(orders!=null){
            ordersMapper.removeDetail(id);
            ordersMapper.deleteByCustomerId(id);
        }
        return customerVoMapper.delete(id);

    }

    @Override
    public boolean update(CustomerVo customerVo) {
        return customerVoMapper.update(customerVo);
    }


    @Override
    public PageInfo selectPage(int pageNo, int pageSize, Object userExample) {
        return null;
    }

    @Override
    public int deleteByPrimaryKey(Serializable serializable) {
        return 0;
    }

    @Override
    public int insert(BaseEntity record) {
        return 0;
    }

    @Override
    public int insertSelective(BaseEntity record) {
        return 0;
    }

    @Override
    public List selectByExample(Object example) {
        return null;
    }

    @Override
    public BaseEntity selectByPrimaryKey(Serializable serializable) {
        return null;
    }

    @Override
    public int updateByPrimaryKeySelective(BaseEntity record) {
        return 0;
    }

    @Override
    public int updateByPrimaryKey(BaseEntity record) {
        return 0;
    }

    @Override
    public boolean deleteByCustomerId(Integer id) {
        return false;
    }


}
